home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 February / CHIPCD_02_2002.iso / Internet / Macromedia ColdFusion Server 5 / coldfusion-50-win-us.exe / data1.cab / Examples / CFDOCS / snippets / structdelete.cfm < prev    next >
Encoding:
Text File  |  2001-06-13  |  2.3 KB  |  57 lines

  1. <!--- This example shows how to use the StructDelete
  2.       function. It calls the CF_ADDEMPLOYEE custom tag,
  3.       which uses the addemployee.cfm file. --->
  4. <html>
  5. <head>
  6. <title>StructDelete Function</title>
  7. </head>
  8. <BASEFONT FACE="Arial, Helvetica" SIZE=2>
  9. <BODY  bgcolor="#FFFFD5">
  10. <h3>StructDelete Function</h3>
  11. <h3>Add New Employees</h3>
  12. <P>
  13. This example uses the StructDelete function. To run this snippet
  14. under UNIX, you must add employee ID generation logic 
  15. to the addemployee.cfm file.
  16. <!--- Establish parms for first time through  --->
  17. <!--- This example shows how to use the StructDelete function. ---><html><head>
  18. <title>StructDelete Function</title></head>
  19. <BASEFONT FACE="Arial, Helvetica" SIZE=2><BODY  bgcolor="#FFFFD5">
  20. <h3>StructDelete Function</h3><P>
  21. This example uses the StructInsert and StructDelete functions. 
  22. <!--- Establish parms for first time through  --->
  23. <CFPARAM name="firstname" default="Mary">
  24. <CFPARAM name="lastname" default="Torvath">
  25. <CFPARAM name="email" default="mtorvath@allaire.com">
  26. <CFPARAM name="phone" default="777-777-7777">
  27. <CFPARAM name="department" default="Documentation"> 
  28.  <CFIF IsDefined("FORM.Delete")>  
  29.  <CFOUTPUT>  
  30.  Field to be deleted: #form.field#
  31.  </CFOUTPUT>  
  32.  <P>    
  33.  <CFSCRIPT>     
  34.      employee=StructNew();
  35.     StructInsert(employee, "firstname", firstname);
  36.     StructInsert(employee, "lastname", lastname);
  37.     StructInsert(employee, "email", email);
  38.     StructInsert(employee, "phone", phone);
  39.     StructInsert(employee, "department", department);     </CFSCRIPT>
  40.     <CFOUTPUT>employee is a structure: #IsStruct(employee)#</CFOUTPUT>
  41.      <CFSET rc = StructDelete(employee, form.field, "True")>      
  42.     <CFOUTPUT>
  43.     <P>Did I delete the field "#form.field#"? The code indicates: #rc#      </P>
  44.     </CFOUTPUT>
  45. </CFIF>    
  46.  
  47. <CFIF NOT IsDefined("FORM.Delete")>    
  48. <FORM action="structdelete.cfm" method="post">
  49.         <P>Select the field to be deleted:         <SELECT name="field">
  50.         <OPTION VALUE="firstname">first name
  51.         <OPTION VALUE="lastname">last name        <OPTION VALUE="email">email
  52.         <OPTION VALUE="phone">phone        <OPTION VALUE="department">department
  53.         </SELECT>        <input type="submit" name="Delete" value="Delete">
  54.  </FORM>
  55.  </CFIF>
  56.  </BODY>
  57.  </HTML>